/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.dozor;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class ActiveLeg implements MessagePayload {
	public float lat1;
	public float lon1;
	public short alt1;
	public float lat2;
	public float lon2;
	public short alt2;
	public short radius;
	
	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putFloat(lat1);
		bb.putFloat(lon1);
		bb.putShort(alt1);
		bb.putFloat(lat2);
		bb.putFloat(lon2);
		bb.putShort(alt2);
		bb.putShort(radius);
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		lat1 = bb.getFloat();
		lon1 = bb.getFloat();
		alt1 = bb.getShort();
		lat2 = bb.getFloat();
		lon2 = bb.getFloat();
		alt2 = bb.getShort();
		radius = bb.getShort();
	}
}
